<template>
    <div class="sea_warp">
       <div class="sea">
            <div v-if="!isshow">
            暂时没有搜到任何商品，尝试其他关键词吧！！！
        </div>
        <div v-if="isshow">
            <span class="coun">为您找到{{coub}}条结果</span>
    <div class="sea_inner">
        <ul class="chearfix">
            <li v-for="(val,ind) in search" :key="ind">
               <p class="im"> <img :src="val.p_img"/></p>
                <p>{{val.p_name}}</p>
                <p>￥{{val.p_price}}</p>
            </li>
        </ul>
    </div>
        </div>
       </div>
    </div>
</template>

<script>
export default {
     inject:['reload'],
data () {
    return {
        isshow:false,
        search:"",
        coub:""
    }
},
created () {
    // console.log(sessionStorage.getItem("search"));
    // this.$axios.post("http://127.0.0.1:8081/client/search",{
    //     search:sessionStorage.getItem("search")
    // }).then(res=>
    // {
    //     console.log(res.data)
    // })
//    this.reload();
this.$axios.post("http://127.0.0.1:8081/client/search",{searchs:this.$route.query.search}).then(res=>
    {
        // console.log("ppp",res.data.val[0][0].counts)
        if(res.data.val[0][0].counts==0)
        {
            this.isshow=false;
        }
        else{
             this.isshow=true;
            this.search=res.data.val[1];
            this.coub=res.data.val[0][0].counts;
        }
    })
    console.log(this.search)
    // if(localStorage.search==undefined)
    // {
    //     this.isshow=false;
    // }
    // else{
    //     this.isshow=true;
    //     this.search=JSON.parse(localStorage.search);
    //     this.coub=localStorage.count;
    // }
    console.log(this.search);
}
}
</script>

<style>
.sea_warp{
    padding-bottom: 100px;
    background: #f2f2f2;
}
.sea{
    width: 1080px;
    margin: 0 auto;
}
.chearfix::after{
        clear: both;
    display: block;
    height: 0;
    overflow: hidden;
    /* font-size: 0; */
    content: ""
}
.sea_inner li{
    float: left;
    width: 266px;

}
.sea_inner .im{
    text-align: center
}
.sea_inner img{
    width: 190px;;
}
</style>
